package cn.edu.bupt.freewings.forum.server.rest;

import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.apache.log4j.Logger;
import cn.edu.bupt.freewings.forum.common.PostType;
import cn.edu.bupt.freewings.forum.common.TopicType;
import cn.edu.bupt.freewings.forum.persistence.Post;
import cn.edu.bupt.freewings.forum.persistence.PostDAO;
import cn.edu.bupt.freewings.forum.server.Utility.Converter;

/**
 * @author hubaiyu (hubaiyu@gmail.com)
 *
 */
@Path("/posts")
public class PostsResource {
	private static Logger logger = Logger.getLogger(PostsResource.class);
	
	@GET
	@Path("/{topicId}")
	@Produces({"application/proto", "application/xml"})
	public PostType.PostList getPostListByTopicId(@PathParam("topicId") Integer topicId){
		List<Post> postList = new PostDAO().getByTopicId(topicId);
		return Converter.postListToPostTypeList(postList, topicId);
	}
}
